
<html>
<head>
<meta charset="UTF-8">
<title>我的表模型库信息列表</title>
<link href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js"></script>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<script type="text/javascript">

	function doAdd(){
		JLEUtil.createModalWin('新增', 'ProjectTmInfoAdd.html');
	}
	
	function doUpdate() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			JLEUtil.createModalWin('修改', 'ProjectTmInfoUpdate.html?' + 'projectId=' + row.projectId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doEdit() {
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLUtil
					.linkNewPage("TableProjectIndex.html?projectId="
							+ row.projectId + '&projectName=' + row.projectName);
		} else {
			$.messager.alert('提示', '请选择数据模型库！');
		}
	}
	
	function doUpdateDBMS() {
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('修改数据模型库当前DBMS',
					'ProjectTmDbmsUpdate.html?projectId='
							+ row.projectId);
		} else {
			$.messager.alert('提示', '请选择表模型库！');
		}
	}
	
	function doCheck() {
		var row = $('#dg').datagrid('getSelected');
		if (!row) {
			$.messager.alert('提示', '请选择表模型库！');
		}
		var projectId = row.projectId;
		//$('#dg').datagrid('loading', true);
		$.ajax({ 
			url:`../../api/project/tm/checkall`,
			type:"POST",
			data:JSON.stringify({ projectId : projectId}),
			contentType:"application/json;charset=utf-8",
			dataType:"json",
			async:true,
			success: function(data) {
				//$('#dg').datagrid('loaded', false);
				if (data.rows == '0') {
					$.messager.alert('提示', '表模型库校验通过！', 'info');
				} else {
					JLEUtil.createModalWin(`${row.projectName}表模型库校验结果`, `ProjectTmCheckList.html?projectId=${projectId}`);
				}
			} 
		});
		
	}	
	
	
	function doDelete(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('删除提示', '你确定要删除表模型库吗?', function(r){
				if (r){
					var jsonData = JSON.parse('{'+'"projectId":"' + row.projectId + '"'+'}');
					$.restfulDelete('../../api/project/tm/info', jsonData, function(data) {
						$.messager.alert('提示','表模型库已转移到待删除队列!','info');
						$('#dg').datagrid('reload');
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doView(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','ProjectTmInfoView.html?' + '&projectId=' + row.projectId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}	

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};
	
	//下载数据库表结构word
	function doGenerateWord(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			var projectId = row.projectId;
			window.location.href = '../../api/project/tableModel/word/downLoad/' + projectId;
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	//下载数据库表结构word
	function doGenerateExcel(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			var projectId = row.projectId;
			window.location.href = '../../api/project/tableModel/excel/downLoad/' + projectId;
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	//下载数据库脚本文件
	function doGenerateScript(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			var projectId = row.projectId;
			//$.restfulGet('../../api/project/ddlSqlScript/downLoad/' + projectId, null, null);
			window.location.href = '../../api/project/ddlSqlScript/downLoad/' + projectId;
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',title:''" style="height: 40px; background: #F4F4F4;">
	<form id="searchForm">
		<table>
			<tr>
				<td>&nbsp;表模型库代码：</td>
				<td><input name="projectCode" id="projectCode"/></td>
				<td>&nbsp;表模型库名称：</td>
				<td><input name="projectName" id="projectName"/></td>
				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.queryForm('searchForm','dg','../../api/my/project/tm/infos');">查找</a></td>
				<td><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
			</tr>
		</table>
	</form>
</div>
<div data-options="region:'center',split:false">
<table id="dg" class="easyui-datagrid" title="" style="width:100%;height:100%"
			data-options="singleSelect:true,collapsible:true,url:'../../api/my/project/tm/infos',method:'post'"
			toolbar="#tb"
		title="Load Data" 
		rownumbers="true" pagination="true" pageSize="20">
		<thead>
			<tr>
				<th data-options="field:'projectCode',resizable:true" width="13%">表模型库代码</th>
				<th data-options="field:'projectName',resizable:true" width="18%">表模型库名称</th>
				<th data-options="field:'projectVersion',resizable:true" width="9%" align="center">表模型库版本</th>
				<th data-options="field:'projectInnerId',resizable:true" hidden="true">表模型库内部标识</th>
				<th data-options="field:'projectDbms',resizable:true" width="12%" align="center" formatter="formatter_PUB_DBMS_ID">表模型库DBMS</th>				
				<th data-options="field:'createUser',resizable:true" width="13%" align="center">创建者</th>
				<th data-options="field:'createTime',resizable:true" width="13%" align="center">创建时间</th>
				<th data-options="field:'projectDesc',resizable:true" width="20%">表模型库描述</th>
				<th data-options="field:'lastModifyUser',resizable:true" hidden="true">>最近修改用户</th>
				<th data-options="field:'lastModifyTime',resizable:true" hidden="true">>最近修改时间</th>
			</tr>
		</thead>
	</table>
</div>
	<div id="tb" style="padding: 1px">
		<div style="margin-bottom: 2px">
			<a href="javascript:doAdd()" class="easyui-linkbutton"
				iconCls="icon-add" plain="true">创建表模型库</a> <a
				href="javascript:doEdit()" class="easyui-linkbutton"
				iconCls="icon-edit" plain="true">编辑表模型库</a> <a
				href="javascript:doCheck()" class="easyui-linkbutton"
				iconCls="icon-ok" plain="true">校验表模型库</a> <a href="#"
				class="easyui-menubutton"
				data-options="menu:'#projectOptionMenu',iconCls:'icon-man'"
				plain="true">管理表模型库</a> <a href="#" class="easyui-menubutton"
				data-options="menu:'#exportMenu',iconCls:'icon-tip'" plain="true">生成文档</a>
		</div>
	</div>
	<div id="projectOptionMenu" style="width: 180px;">
		<div onclick="doUpdate()">表模型库信息修改</div>
		<div onclick="doUpdateDBMS()">表模型库DBMS修改</div>
		<div onclick="doDelete()">表模型库删除</div>
		<div onclick="doUpdateAuth()">表模型库权限管理</div>
	</div>
	<div id="exportMenu" style="width: 150px;">
		<div onclick="doGenerateWord()">生成Word文档</div>
		<div onclick="doGenerateExcel()">生成Excel文档</div>
		<div onclick="doGenerateScript()">生成数据库脚本</div>		
		<!--<div onclick="doGeneratePDF()">生成PDF文档</div>-->
	</div>
</body>
</html>

